<!DOCTYPE html>





<html class="theme-next muse use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="generator" content="Hexo 3.9.0">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=7.3.0">
  <link rel="mask-icon" href="/images/logo.svg?v=7.3.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.3.0">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '7.3.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    save_scroll: false,
    copycode: {"enable":false,"show_result":false,"style":null},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: '',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    }
  };
</script>

  <meta name="description" content="简介ASN.1 全称 Abstract Syntax Natation One. 是一个用来描述抽象类型抽象数据的语法. 类似于 XML, JSON 等, 主要用于编码数据以便于在网络中交换数据.   在线解析工具：https://lapo.it/asn1js/  ASN.1编码方式ASN.1 中定义四种类型 简单类型 (Simple types) : 用于编码基本的数据类型. 如 整形,字符串,">
<meta name="keywords" content="V2X">
<meta property="og:type" content="article">
<meta property="og:title" content="C-V2X之ASN.1">
<meta property="og:url" content="http://yoursite.com/2019/07/17/V2x之ASN.1/index.html">
<meta property="og:site_name" content="XuQi&#39;s Blog">
<meta property="og:description" content="简介ASN.1 全称 Abstract Syntax Natation One. 是一个用来描述抽象类型抽象数据的语法. 类似于 XML, JSON 等, 主要用于编码数据以便于在网络中交换数据.   在线解析工具：https://lapo.it/asn1js/  ASN.1编码方式ASN.1 中定义四种类型 简单类型 (Simple types) : 用于编码基本的数据类型. 如 整形,字符串,">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://yoursite.com/2019/07/17/V2x之ASN.1/1563332529996.png">
<meta property="og:image" content="http://yoursite.com/2019/07/17/V2x之ASN.1/1563333599659.png">
<meta property="og:updated_time" content="2019-10-20T13:23:23.045Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="C-V2X之ASN.1">
<meta name="twitter:description" content="简介ASN.1 全称 Abstract Syntax Natation One. 是一个用来描述抽象类型抽象数据的语法. 类似于 XML, JSON 等, 主要用于编码数据以便于在网络中交换数据.   在线解析工具：https://lapo.it/asn1js/  ASN.1编码方式ASN.1 中定义四种类型 简单类型 (Simple types) : 用于编码基本的数据类型. 如 整形,字符串,">
<meta name="twitter:image" content="http://yoursite.com/2019/07/17/V2x之ASN.1/1563332529996.png">
  <link rel="canonical" href="http://yoursite.com/2019/07/17/V2x之ASN.1/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>C-V2X之ASN.1 | XuQi's Blog</title>
  








  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  <div class="container sidebar-position-left">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">XuQi's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>
  </ul>

    

</nav>
</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content page-post-detail">
            

  <div id="posts" class="posts-expand">
    

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/07/17/V2x之ASN.1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="XuQi">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="XuQi's Blog">
    </span>
      <header class="post-header">

        
          <h1 class="post-title" itemprop="name headline">C-V2X之ASN.1

            
          </h1>
        

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2019-07-17 09:53:00" itemprop="dateCreated datePublished" datetime="2019-07-17T09:53:00+00:00">2019-07-17</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-10-20 13:23:23" itemprop="dateModified" datetime="2019-10-20T13:23:23+00:00">2019-10-20</time>
              </span>
            
          

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h2><p>ASN.1 全称 Abstract Syntax Natation One. 是一个用来描述抽象类型抽象数据的语法. 类似于 XML, JSON 等, 主要用于编码数据以便于在网络中交换数据. </p>
<blockquote>
<p>在线解析工具：<a href="https://lapo.it/asn1js/" target="_blank" rel="noopener">https://lapo.it/asn1js/</a></p>
</blockquote>
<h3 id="ASN-1编码方式"><a href="#ASN-1编码方式" class="headerlink" title="ASN.1编码方式"></a>ASN.1编码方式</h3><h4 id="ASN-1-中定义四种类型"><a href="#ASN-1-中定义四种类型" class="headerlink" title="ASN.1 中定义四种类型"></a>ASN.1 中定义四种类型</h4><ul>
<li><p>简单类型 (Simple types) : 用于编码基本的数据类型. 如 整形,字符串,二进制数据等.</p>
</li>
<li><p>结构类型 (Structured types) : 用于编码复杂数据类型. 如, X509 证书中的公钥.</p>
</li>
<li><p>标记的类型 (Tagged types) : 用于编码从其他几种类型引申而来的类型.</p>
</li>
<li><p>其他类型 (Other types) : CHOICE 或 Any.</p>
<a id="more"></a>

</li>
</ul>
<p><strong>简单类型</strong></p>
<table>
<thead>
<tr>
<th><strong>Type</strong></th>
<th><strong>Descrption</strong></th>
</tr>
</thead>
<tbody><tr>
<td>BIT STRING</td>
<td>由任意的 0 和 1 构成的字符串</td>
</tr>
<tr>
<td>IA5String</td>
<td>任意的 ASCII 字符串</td>
</tr>
<tr>
<td>INTEGER</td>
<td>任意的整型</td>
</tr>
<tr>
<td>NULL</td>
<td>表示空值</td>
</tr>
<tr>
<td>OBJECT IDENTIFIER</td>
<td>由一系列的整型序列组成</td>
</tr>
<tr>
<td>OCTET STRING</td>
<td>由八比特值构成的字符串, 类似于比特数组</td>
</tr>
<tr>
<td>PrintableString</td>
<td>由任意的可打印字符构成的字符串</td>
</tr>
<tr>
<td>T61String</td>
<td>由八比特字符构成的字符串</td>
</tr>
<tr>
<td>UTCTime    GMT</td>
<td>时间值</td>
</tr>
</tbody></table>
<p><strong>结构类型</strong></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Descrption</th>
</tr>
</thead>
<tbody><tr>
<td>SEQUENCE</td>
<td>一个有序的类型集合</td>
</tr>
<tr>
<td>SEQUENCE OF</td>
<td>一个给定类型的有序集合</td>
</tr>
<tr>
<td>SET</td>
<td>一个无序的类型集合</td>
</tr>
<tr>
<td>SET OF</td>
<td>一个给定类型的无序集合</td>
</tr>
</tbody></table>
<p><strong>ASN.1 中每个类型都对应与一个 class 和 非负的 tag number. 用来区别不同的 ASN.1 类型.</strong></p>
<h4 id="ASN-1-中定义四种-class"><a href="#ASN-1-中定义四种-class" class="headerlink" title="ASN.1 中定义四种 class"></a>ASN.1 中定义四种 class</h4><ul>
<li><p>Universal: 用来表示在所有应用中都具有相同意义的类型. 这些类型定义在 X.208</p>
</li>
<li><p>Application: 用来表示针对于具体应用的类型. 在不同的应用中这些类型的意义往往不同</p>
</li>
<li><p>Private: 用来表示针对用于具体企业的类型</p>
</li>
<li><p>Context-specific: 用来表示针对于具体上下文该类型意义会变化的类型</p>
</li>
</ul>
<p><strong>Tag Numbers</strong></p>
<table>
<thead>
<tr>
<th><strong>Type</strong></th>
<th><strong>Tag Number (hexadecimal)</strong></th>
</tr>
</thead>
<tbody><tr>
<td>INTEGER</td>
<td>02</td>
</tr>
<tr>
<td>BIT STRING</td>
<td>03</td>
</tr>
<tr>
<td>OCTET STRING</td>
<td>04</td>
</tr>
<tr>
<td>NULL</td>
<td>05</td>
</tr>
<tr>
<td>OBJECT IDENTIFIER</td>
<td>06</td>
</tr>
<tr>
<td>SEQUENCE and SEQUENCE OF</td>
<td>10</td>
</tr>
<tr>
<td>SET and SET OF</td>
<td>11</td>
</tr>
<tr>
<td>PrintableString</td>
<td>13</td>
</tr>
<tr>
<td>T61String</td>
<td>14</td>
</tr>
<tr>
<td>IA5String</td>
<td>16</td>
</tr>
<tr>
<td>UTCTime</td>
<td>17</td>
</tr>
</tbody></table>
<h4 id="BER-Basic-Encoding-Rules"><a href="#BER-Basic-Encoding-Rules" class="headerlink" title="BER (Basic Encoding Rules)"></a>BER (Basic Encoding Rules)</h4><h4 id="三种编码方法"><a href="#三种编码方法" class="headerlink" title="三种编码方法"></a>三种编码方法</h4><p>规定了如何将 ASN.1 值表示为比特数组,针对不同给数据类型, BER 规定了如下三种编码方法: </p>
<h5 id="Primitive-definte-length-encoding"><a href="#Primitive-definte-length-encoding" class="headerlink" title="Primitive, definte-length encoding"></a>Primitive, definte-length encoding</h5><p>基本数据类型<strong>除字符串类型外</strong>均使用这种编码方式. 这种情况下我们的数据编码结果会是以下形式:</p>
<p><img src="/2019/07/17/V2x之ASN.1/1563332529996.png" alt="1563332529996"></p>
<p>其中不包含 End-of-contents 部分, 因为这里我们使用定长编码.</p>
<h6 id="Identifier"><a href="#Identifier" class="headerlink" title="Identifier"></a>Identifier</h6><ul>
<li><strong>low tag number form</strong>: 这种形式下, Identifier 仅用一个字节表示. bit8 和 bit7 用来表示 class, bit6 为 0, 用来表示是基本类型. bit5-1表示 tag number.</li>
<li><strong>high tag number form</strong>: 这种形式下, Identifier 会占用一到多个字节. 第一个字节任然是 low tag number form 形式. 但是 bit5-1 应该全为 1. 其余比特用来表示 tag number, 高字节在前.</li>
</ul>
<h6 id="Length"><a href="#Length" class="headerlink" title="Length"></a>Length</h6><ul>
<li><strong>Short form</strong>: 这种形式下, Length 占用一个字节. bit 8 为 0, 其余七字节用于编码长度, 因此这种形式用于表示长度 0-127.</li>
<li><strong>Long form</strong>: 这种形式下, Length 占用的字节长度为 2-127 个字节. 第一个字节的 bit8 为 1, 其余字节用于表示紧接着有多少个字节用来编码长度. 高字节在前.</li>
</ul>
<h5 id="Contructed-definite-length-encoding"><a href="#Contructed-definite-length-encoding" class="headerlink" title="Contructed, definite-length encoding"></a>Contructed, definite-length encoding</h5><p>这种编码方法用于编码复杂类型和简单类型中的字符串类型且<strong>编码长度已知</strong>.编码形式与 Primitive, definte-length encoding 类似. 除了 Identifier 字段的第一个字节的 bit6 为 1 (0x20), 用来表示是复杂类型.</p>
<h5 id="Constructed-indefinite-length-encoding"><a href="#Constructed-indefinite-length-encoding" class="headerlink" title="Constructed, indefinite-length encoding"></a>Constructed, indefinite-length encoding</h5><p>这种编码方法用于编码复杂类型和简单类型中的字符串类型且<strong>编码长度未知</strong>.编码形式如下:</p>
<p><img src="/2019/07/17/V2x之ASN.1/1563333599659.png" alt="1563333599659"></p>
<p>这里 Length 字段的值为 0x80, End-of-contents 字段的值为两个字节的 0. 表示该编码方式为不定长编码.其余字段的编码与 Contructed, definite-length encoding 类似.</p>
<h4 id="DER-Distinguished-Encoding-Rules"><a href="#DER-Distinguished-Encoding-Rules" class="headerlink" title="DER(Distinguished Encoding Rules)"></a>DER(Distinguished Encoding Rules)</h4><p>是 DER 编码的一个子集. 区别在于 BER 编码结果不唯一, 而 DER 编码结果唯一</p>
<ul>
<li>当编码长度在 0-127 之间时, 必须使用 short form 形式编码 Length 字段</li>
<li>当编码长度大于 128 时, 必须使用 long form 形式且应使用最少的字节对长度进行编码,也就是说如果长度为192, 那么 Length 字段只能占两个字节. <strong>第一个字节为0x81, 表示 Length 字段使用 Long form</strong>, 且紧接着只有一个字节用于编码长度信息. <strong>第二个字节为 0xc0, 用来表示长度为 192</strong></li>
<li>对于简单字符串类型, 必须使用 primitive, definite-length 进行编码</li>
<li>对于复杂类型, 必须使用 constructed definite-length 进行编码</li>
</ul>
<h4 id="编码示例"><a href="#编码示例" class="headerlink" title="编码示例"></a>编码示例</h4><h5 id="BIT-STRING-由任意的-0-和-1-构成的字符串"><a href="#BIT-STRING-由任意的-0-和-1-构成的字符串" class="headerlink" title="BIT STRING (由任意的 0 和 1 构成的字符串)"></a>BIT STRING (由任意的 0 和 1 构成的字符串)</h5><p>对 “00000110011011100101110111000000” 进行编码 (<strong>06 6E 5D C0</strong>),</p>
<p>对于 BIT STRING 类型, Identifier 字段应该为 03(这里我们不考虑 class, 仅仅考虑 tag number). 对于 Length 字段, 因为每个1或者0代表一个bit, 因此该值需要 4 字节进行编码, 因此 Length 字段应该为 04.</p>
<p>编码结果为:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">BER short form encoding/DER encoding: 03 04 06 6e 5d c0</span><br><span class="line">BER long form encoding: 03 81 04 06 6e 5d c0</span><br></pre></td></tr></table></figure>

<h5 id="IA5String-任意的-ASCII-字符串"><a href="#IA5String-任意的-ASCII-字符串" class="headerlink" title="IA5String (任意的 ASCII 字符串)"></a>IA5String (任意的 ASCII 字符串)</h5><ol>
<li>对 “<a href="mailto:test1@rsa.com" target="_blank" rel="noopener">test1@rsa.com</a>“ 进行编码, 编码结果为:</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">BER short form encoding/DER encoding: 16 0d 74 65 73 74 31 40 72 73 61 2e 63 6f 6d</span><br><span class="line">BER long form encoding: 16 81 0d 74 65 73 74 31 40 72 73 61 2e 63 6f 6d</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>“test1@rsa.com” 编码为一个 IA5String 的集合, 该集合中由三个 IA5String 构成: “<strong>test1</strong>”, “<strong>@</strong>”, “<strong>rsa.com</strong>”.</li>
</ol>
<p>这里我们要编码一个复杂类型, 那么 Identifier 的 bit6 应该为 1 (0x20), 代表复杂类型. 而 IA5String 的 tag number 为 0x16, 因此 Identifier 的值应该为 0x36. 因此编码结果如下:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">36 13  					// 0x20 + 0x16  Length = 0x13                    </span><br><span class="line">16 05 74 65 73 74 31  	// 16 IA5String  test1</span><br><span class="line">16 01 40  				// 16 IA5String @</span><br><span class="line">16 07 72 73 61 2e 63 6f 6d // 16 IA5String rsa.com</span><br></pre></td></tr></table></figure>

<h5 id="INTEGER"><a href="#INTEGER" class="headerlink" title="INTEGER"></a>INTEGER</h5><p>对 0 进行编码, 编码结果如下: <code>02 01 00</code><br>对 127 进行编码, 编码结果如下: <code>02 01 7F</code><br>对 128 进行编码, 编码结果如下: <code>02 02 00 80</code></p>
<h5 id="NULL"><a href="#NULL" class="headerlink" title="NULL"></a>NULL</h5><p>编码结果为: <code>05 00</code> 或 <code>05 81 00</code></p>
<h5 id="OCTET-STRING-由八比特值构成的字符串-类似于比特数组"><a href="#OCTET-STRING-由八比特值构成的字符串-类似于比特数组" class="headerlink" title="OCTET STRING (由八比特值构成的字符串, 类似于比特数组)"></a>OCTET STRING (由八比特值构成的字符串, 类似于比特数组)</h5><p>对 01 23 45 67 89 ab cd ef 进行编码, 编码结果如下: <code>04 08 01 23 45 67 89 ab cd ef</code></p>
<h5 id="UTCTime"><a href="#UTCTime" class="headerlink" title="UTCTime"></a>UTCTime</h5><p>将要进行 ANS1 编码的 UTCTime 应该是以下形式之一:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">YYMMDDhhmmZ</span><br><span class="line">YYMMDDhhmm+hh&apos;mm&apos;</span><br><span class="line">YYMMDDhhmm-hh&apos;mm&apos;</span><br><span class="line">YYMMDDhhmmssZ</span><br><span class="line">YYMMDDhhmmss+hh&apos;mm&apos;</span><br><span class="line">YYMMDDhhmmss-hh&apos;mm&apos;</span><br><span class="line"></span><br><span class="line">where:</span><br><span class="line"></span><br><span class="line">YY is the least significant two digits of the year</span><br><span class="line">MM is the month (01 to 12)</span><br><span class="line">DD is the day (01 to 31)</span><br><span class="line">hh is the hour (00 to 23)</span><br><span class="line">mm are the minutes (00 to 59)</span><br><span class="line">ss are the seconds (00 to 59)</span><br><span class="line">Z indicates that local time is GMT, + indicates that local time is later than GMT, and - indicates that local time is earlier than GMT</span><br><span class="line">hh&apos; is the absolute value of the offset from GMT in hours</span><br><span class="line">mm&apos; is the absolute value of the offset from GMT in minutes</span><br></pre></td></tr></table></figure>

<p>对于时间 4:45:40 p.m. Pacific Daylight Time on May 6, 1991 进行编码,<br>它的所有表示形式中存在以下两种:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">&quot;910506164540-0700&quot;</span><br><span class="line">&quot;910506234540Z&quot;</span><br></pre></td></tr></table></figure>

<p>对他们进行编码的结果为:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">17 11 39 31 30 35 30 36 31 36 34 35 34 30 2D 30 37 30 30</span><br><span class="line">17 0d 39 31 30 35 30 36 32 33 34 35 34 30 5a</span><br></pre></td></tr></table></figure>

<h5 id="OBJECT-IDENTIFIER-由一系列的整型序列组成"><a href="#OBJECT-IDENTIFIER-由一系列的整型序列组成" class="headerlink" title="OBJECT IDENTIFIER (由一系列的整型序列组成)"></a>OBJECT IDENTIFIER (由一系列的整型序列组成)</h5><p><strong>编码规则：</strong></p>
<ol>
<li><p>编码后的<strong>第一个字节</strong>的值为 40 * value1 + value2. (value1 要求是 0, 1 或者 2. value2 要求是 0-39.)</p>
</li>
<li><p>接下来的 value3, value4, …, valuen 以 128 为 base 进行编码, 高字节在前. 每个数字编码后除了最后一个字节外其他字节的 bit8 均为 1</p>
</li>
</ol>
<p>对于序列：{ 1, 2, 840,113549 }进行编码:</p>
<p>第一字节 value1  = 1, value2 = 2  40 * 1 + 2 =42 = 0x2A ，编码为0x2A </p>
<p>第二字节840 = 6 * 128 + 72，第二字节应该编码的值是 value1  =0x06 且 bit8 为 1，编码为 0x06 + 0x80 = 0x86</p>
<p>第三字节 为前面的value2= 72，编码为0x48</p>
<p>第四字节113549 = 6 * 128 * 128 + 119 * 128 + 13 ，编码为0x80 + 0x06 = 0x86</p>
<p>第五字节 119=0x77  编码为 0x80+0x77 = 0xF7</p>
<p>第六字节 13 = 0x0d 编码为0x0d</p>
<p>最终编码为：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">06 06 2a 86 48 86 f7 0d</span><br></pre></td></tr></table></figure>

<h3 id="ASN-1的基本语法规则"><a href="#ASN-1的基本语法规则" class="headerlink" title="ASN.1的基本语法规则"></a>ASN.1的基本语法规则</h3><table>
<thead>
<tr>
<th>符号</th>
<th>含义</th>
</tr>
</thead>
<tbody><tr>
<td>::=</td>
<td>定义为</td>
</tr>
<tr>
<td>|</td>
<td>或</td>
</tr>
<tr>
<td>–</td>
<td>后面是注释(行)</td>
</tr>
<tr>
<td>{}</td>
<td>清单的开始和结束</td>
</tr>
<tr>
<td>[]</td>
<td>标签的开始和结束</td>
</tr>
<tr>
<td>()</td>
<td>子类型的开始和结束</td>
</tr>
<tr>
<td>..</td>
<td>范围</td>
</tr>
<tr>
<td>…</td>
<td>为了方便在新的版本中往现有类型中添加新成员，可用“…”来标记可能以后是其它类型的地方：</td>
</tr>
</tbody></table>
<h4 id="类型定义与类型"><a href="#类型定义与类型" class="headerlink" title="类型定义与类型"></a>类型定义与类型</h4><p><strong>&lt;新类型的名字&gt; ::= &lt;类型描述&gt;</strong></p>
<p><strong>值定义：&lt;新的值的名字&gt; &lt;该值的类型&gt; ::= &lt;值描述&gt;</strong></p>
<ul>
<li>&lt;新的值的名字&gt;是以小写字母开头的标识符；</li>
<li>&lt;该值的类型&gt;可以是一个类型的名字，也可以是类型描述；</li>
<li>&lt;值描述&gt;是基于整数、字符串、标识符的组合。</li>
</ul>
<h5 id="示例"><a href="#示例" class="headerlink" title="示例"></a><strong>示例</strong></h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">TestModule DEFINITIONS ::= BEGIN -- Module parameters preamble</span><br><span class="line"> Circle ::= SEQUENCE &#123; -- Definition of Circle type</span><br><span class="line">	position-x INTEGER, -- Integer position</span><br><span class="line"> 	position-y INTEGER, -- Position along Y-axis</span><br><span class="line"> 	radius INTEGER (0..MAX) -- Positive radius</span><br><span class="line"> &#125; -- End of Circle type</span><br><span class="line">END -- End of TestModule</span><br></pre></td></tr></table></figure>

<p><strong>BSM.asn</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line">-- 导入时，FROM后的名字</span><br><span class="line">BSM DEFINITIONS AUTOMATIC TAGS ::= BEGIN</span><br><span class="line"></span><br><span class="line">-- imports and exports</span><br><span class="line">-- 导出的类型是BasicSafetyMessage</span><br><span class="line">EXPORTS BasicSafetyMessage;</span><br><span class="line">-- 导入类型，以下类型非本文件定义</span><br><span class="line">IMPORTS AccelerationSet4Way FROM DefAcceleration</span><br><span class="line">		BrakeSystemStatus FROM VehBrake</span><br><span class="line">		VehicleSize FROM VehSize</span><br><span class="line">		Position3D, PositionConfidenceSet FROM DefPosition</span><br><span class="line">		DSecond FROM DefTime</span><br><span class="line">		TransmissionState FROM VehStatus</span><br><span class="line">		Speed, Heading, SteeringWheelAngle, MotionConfidenceSet FROM DefMotion</span><br><span class="line">		MsgCount FROM MsgFrame</span><br><span class="line">		VehicleClassification FROM VehClass</span><br><span class="line">		VehicleSafetyExtensions FROM VehSafetyExt;</span><br><span class="line">	</span><br><span class="line">	-- BasicSafetyMessage是一个有序类型的集合</span><br><span class="line">	BasicSafetyMessage ::=SEQUENCE &#123;</span><br><span class="line">		msgCnt MsgCount,</span><br><span class="line">		-- vehicle ID 由八比特值构成的字符串, 类似于比特数组</span><br><span class="line">		id OCTET STRING (SIZE(8)), </span><br><span class="line">		-- Reserved for Electronic Vehicle Identification，可选，大小在4~16字节</span><br><span class="line">		plateNo OCTET STRING (SIZE(4..16)) OPTIONAL,</span><br><span class="line">		</span><br><span class="line">		secMark DSecond,</span><br><span class="line">		pos Position3D,</span><br><span class="line">		accuracy PositionConfidenceSet,</span><br><span class="line">		transmission TransmissionState,</span><br><span class="line">		speed Speed,</span><br><span class="line">		heading Heading,</span><br><span class="line">		angle SteeringWheelAngle OPTIONAL,</span><br><span class="line">		motionCfd MotionConfidenceSet OPTIONAL,</span><br><span class="line">		accelSet AccelerationSet4Way,</span><br><span class="line">		brakes BrakeSystemStatus,</span><br><span class="line">		size VehicleSize,</span><br><span class="line">		vehicleClass VehicleClassification,</span><br><span class="line">		-- VehicleClassification includes BasicVehicleClass and other extendible type</span><br><span class="line">		safetyExt VehicleSafetyExtensions OPTIONAL,</span><br><span class="line">		...</span><br><span class="line">		-- 为了方便在新的版本中往现有类型中添加新成员，可用“…”来标记可能以后是其它类型的地方</span><br><span class="line">	&#125;</span><br><span class="line">END</span><br></pre></td></tr></table></figure>

<h3 id="ASN-1-编译开源工具"><a href="#ASN-1-编译开源工具" class="headerlink" title="ASN.1 编译开源工具"></a>ASN.1 编译开源工具</h3><h4 id="下载地址"><a href="#下载地址" class="headerlink" title="下载地址"></a><strong>下载地址</strong></h4><p><a href="https://github.com/vlm/asn1c/releases" target="_blank" rel="noopener">https://github.com/vlm/asn1c/releases</a></p>
<h4 id="编译"><a href="#编译" class="headerlink" title="编译"></a><strong>编译</strong></h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">test -f configure || autoreconf -iv</span><br><span class="line">./configure</span><br><span class="line">make</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>

<h4 id="生成-h和c文件"><a href="#生成-h和c文件" class="headerlink" title="生成.h和c文件"></a><strong>生成.h和c文件</strong></h4><p><strong>新建文件rectangle.asn</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">RectangleModule DEFINITIONS::=BEGIN</span><br><span class="line">Rectangle::=SEQUENCE&#123;</span><br><span class="line">height INTEGER,</span><br><span class="line">width INTEGER</span><br><span class="line">&#125;</span><br><span class="line">END</span><br></pre></td></tr></table></figure>

<p><strong>生成.c和.h文件</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">asn1c  rectangle.asn</span><br></pre></td></tr></table></figure>

<h4 id="编写测试程序"><a href="#编写测试程序" class="headerlink" title="编写测试程序"></a>编写测试程序</h4><p><strong>编码：</strong></p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//</span></span><br><span class="line"><span class="comment">// Created by root on 19-7-17.</span></span><br><span class="line"><span class="comment">//</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;sys/types.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">"Rectangle.h"</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">int</span> <span class="title">write_out</span><span class="params">(<span class="keyword">const</span> <span class="keyword">void</span>*buffer, <span class="keyword">size_t</span> size,<span class="keyword">void</span> *app_key)</span> </span>&#123;</span><br><span class="line">    FILE *out_fp = app_key;</span><br><span class="line">    <span class="keyword">size_t</span> wrote = fwrite(buffer,<span class="number">1</span>,size,out_fp);</span><br><span class="line">    <span class="keyword">return</span> (wrote == size) ? <span class="number">0</span> : <span class="number">-1</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    Rectangle_t *rectangle;</span><br><span class="line">    <span class="keyword">asn_enc_rval_t</span> ec;</span><br><span class="line"></span><br><span class="line">    rectangle = <span class="built_in">calloc</span>(<span class="number">1</span>, <span class="keyword">sizeof</span>(Rectangle_t));</span><br><span class="line"></span><br><span class="line">    rectangle-&gt;height = <span class="number">42</span>;</span><br><span class="line">    rectangle-&gt;width = <span class="number">23</span>;</span><br><span class="line"></span><br><span class="line">   <span class="keyword">const</span> <span class="keyword">char</span> *filename = <span class="string">"./rect.txt"</span>;</span><br><span class="line">   FILE *fp = fopen(filename,<span class="string">"wb"</span>);</span><br><span class="line"></span><br><span class="line">   ec = der_encode(&amp;asn_DEF_Rectangle,rectangle,write_out, fp);</span><br><span class="line">   fclose(fp);</span><br><span class="line"></span><br><span class="line">   xer_fprint(<span class="built_in">stdout</span>, &amp;asn_DEF_Rectangle,rectangle);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><strong>解码：</strong></p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//</span></span><br><span class="line"><span class="comment">// Created by root on 19-7-17.</span></span><br><span class="line"><span class="comment">//</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;sys/types.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">"Rectangle.h"</span></span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    Rectangle_t *rectangle = <span class="number">0</span>;</span><br><span class="line">    </span><br><span class="line"></span><br><span class="line">    <span class="keyword">char</span> buf[<span class="number">1024</span>];</span><br><span class="line">    <span class="keyword">size_t</span> size;</span><br><span class="line"></span><br><span class="line">    rectangle = <span class="built_in">calloc</span>(<span class="number">1</span>, <span class="keyword">sizeof</span>(Rectangle_t));</span><br><span class="line"></span><br><span class="line">    <span class="keyword">const</span> <span class="keyword">char</span> *filename = <span class="string">"./rect.txt"</span>;</span><br><span class="line">    FILE *fp = fopen(filename,<span class="string">"rb"</span>);</span><br><span class="line"></span><br><span class="line">    size = fread(buf,<span class="number">1</span>,<span class="keyword">sizeof</span>(buf),fp);</span><br><span class="line">    fclose(fp);</span><br><span class="line"></span><br><span class="line">    ber_decode(<span class="number">0</span>, &amp;asn_DEF_Rectangle,(<span class="keyword">void</span> **)&amp; rectangle,buf,size);</span><br><span class="line"></span><br><span class="line">    xer_fprint(<span class="built_in">stdout</span>, &amp;asn_DEF_Rectangle,rectangle);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><strong>输出：</strong></p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">Rectangle</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">height</span>&gt;</span>42<span class="tag">&lt;/<span class="name">height</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">width</span>&gt;</span>23<span class="tag">&lt;/<span class="name">width</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">Rectangle</span>&gt;</span></span><br></pre></td></tr></table></figure>


    </div>

    
    
    
        
      

      <footer class="post-footer">
          
            
          
          <div class="post-tags">
            
              <a href="/tags/V2X/" rel="tag"># V2X</a>
            
          </div>
        

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
              
                <a href="/2019/07/09/CMake入门/" rel="next" title="CMake入门">
                  <i class="fa fa-chevron-left"></i> CMake入门
                </a>
              
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
              
                <a href="/2019/07/17/V2X之MATLAB/" rel="prev" title="V2X之MATLAB">
                  V2X之MATLAB <i class="fa fa-chevron-right"></i>
                </a>
              
            </div>
          </div>
        
      </footer>
    
  </div>
  
  
  
  </article>

  </div>


          </div>
          

        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">

          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">XuQi</p>
  <div class="site-description motion-element" itemprop="description"></div>
</div>
  <nav class="site-state motion-element">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">44</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">30</span>
        <span class="site-state-item-name">标签</span>
        
      </div>
    
  </nav>



        </div>
      </div>
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#简介"><span class="nav-number">1.</span> <span class="nav-text">简介</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#ASN-1编码方式"><span class="nav-number">1.1.</span> <span class="nav-text">ASN.1编码方式</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#ASN-1-中定义四种类型"><span class="nav-number">1.1.1.</span> <span class="nav-text">ASN.1 中定义四种类型</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#ASN-1-中定义四种-class"><span class="nav-number">1.1.2.</span> <span class="nav-text">ASN.1 中定义四种 class</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#BER-Basic-Encoding-Rules"><span class="nav-number">1.1.3.</span> <span class="nav-text">BER (Basic Encoding Rules)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#三种编码方法"><span class="nav-number">1.1.4.</span> <span class="nav-text">三种编码方法</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Primitive-definte-length-encoding"><span class="nav-number">1.1.4.1.</span> <span class="nav-text">Primitive, definte-length encoding</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#Identifier"><span class="nav-number">1.1.4.1.1.</span> <span class="nav-text">Identifier</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#Length"><span class="nav-number">1.1.4.1.2.</span> <span class="nav-text">Length</span></a></li></ol></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Contructed-definite-length-encoding"><span class="nav-number">1.1.4.2.</span> <span class="nav-text">Contructed, definite-length encoding</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Constructed-indefinite-length-encoding"><span class="nav-number">1.1.4.3.</span> <span class="nav-text">Constructed, indefinite-length encoding</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#DER-Distinguished-Encoding-Rules"><span class="nav-number">1.1.5.</span> <span class="nav-text">DER(Distinguished Encoding Rules)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#编码示例"><span class="nav-number">1.1.6.</span> <span class="nav-text">编码示例</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#BIT-STRING-由任意的-0-和-1-构成的字符串"><span class="nav-number">1.1.6.1.</span> <span class="nav-text">BIT STRING (由任意的 0 和 1 构成的字符串)</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#IA5String-任意的-ASCII-字符串"><span class="nav-number">1.1.6.2.</span> <span class="nav-text">IA5String (任意的 ASCII 字符串)</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#INTEGER"><span class="nav-number">1.1.6.3.</span> <span class="nav-text">INTEGER</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#NULL"><span class="nav-number">1.1.6.4.</span> <span class="nav-text">NULL</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#OCTET-STRING-由八比特值构成的字符串-类似于比特数组"><span class="nav-number">1.1.6.5.</span> <span class="nav-text">OCTET STRING (由八比特值构成的字符串, 类似于比特数组)</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#UTCTime"><span class="nav-number">1.1.6.6.</span> <span class="nav-text">UTCTime</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#OBJECT-IDENTIFIER-由一系列的整型序列组成"><span class="nav-number">1.1.6.7.</span> <span class="nav-text">OBJECT IDENTIFIER (由一系列的整型序列组成)</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#ASN-1的基本语法规则"><span class="nav-number">1.2.</span> <span class="nav-text">ASN.1的基本语法规则</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#类型定义与类型"><span class="nav-number">1.2.1.</span> <span class="nav-text">类型定义与类型</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#示例"><span class="nav-number">1.2.1.1.</span> <span class="nav-text">示例</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#ASN-1-编译开源工具"><span class="nav-number">1.3.</span> <span class="nav-text">ASN.1 编译开源工具</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#下载地址"><span class="nav-number">1.3.1.</span> <span class="nav-text">下载地址</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#编译"><span class="nav-number">1.3.2.</span> <span class="nav-text">编译</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#生成-h和c文件"><span class="nav-number">1.3.3.</span> <span class="nav-text">生成.h和c文件</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#编写测试程序"><span class="nav-number">1.3.4.</span> <span class="nav-text">编写测试程序</span></a></li></ol></li></ol></li></ol></div>
            

          </div>
        </div>
      <!--/noindex-->
      

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">XuQi</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0</div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> v7.3.0</div>

        








        
      </div>
    </footer>
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
      </div>

    

  </div>

  
  <script src="/lib/jquery/index.js?v=3.4.1"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

<script src="/js/utils.js?v=7.3.0"></script>
  <script src="/js/motion.js?v=7.3.0"></script>


  <script src="/js/schemes/muse.js?v=7.3.0"></script>


<script src="/js/next-boot.js?v=7.3.0"></script>




  




























  

  

  


  
  <script src="/js/scrollspy.js?v=7.3.0"></script>
<script src="/js/post-details.js?v=7.3.0"></script>


</body>
</html>
